/**
 * Created by Superlee on 2016/5/31.
 */
var loginModule = angular.module('LoginModule');

loginModule.directive('passwordFocus', function () {
    return {
        restrict: 'A',
        scope: {
            isPasswordFocus: "=passwordFocus"
        },
        link: function (scope, element, attr) {
            element.bind('focus', function () {
                scope.isPasswordFocus = true;
                scope.$apply(scope.isPasswordFocus);
            });
            element.bind('blur', function () {
                scope.isPasswordFocus = false;
                scope.$apply(scope.isPasswordFocus);
            })
        }
    }
}).directive('focusStep', function () {
    return {
        restrict: 'A',
        scope: false,
        link: function (scope, element, attr) {
            element.bind('focus', function () {
                switch (attr.focusStep) {
                    case '1':
                        scope.step = 1;
                        break;
                    case '2':
                        scope.step = 2;
                        break;
                    case '3':
                        scope.step = 3;
                        break;
                    default:
                        scope.step = 1;
                        break;
                }
                // console.log(scope.step);
                scope.$apply(scope.step);
            });
        }
    }
});

var mainPageModule = angular.module('MainPageModule');

mainPageModule.directive('sidebarSwitch', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attr) {
            element.bind('click', function () {
                angular.element('#mainPage .row-offcanvas').toggleClass('active');
            })
        }
    }
}).directive('childliClick',function(){
    return {
        restrict:'A',
        link:function(scope,element,attr){
            angular.element(element).children('li').bind('click',function(){
                angular.element(element).children('li').removeClass('active');
                angular.element(this).addClass('active');
            });
        }
    }
});